package com.farm.controller;

import com.farm.common.R;
import com.farm.mapper.SusceptibleMapper;
import com.farm.pojo.Susceptible;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/susceptible")
public class susceptibleController {

    @Autowired
    private SusceptibleMapper susceptibleMapper;


    /**
     * 查询敏感词
     * @return
     */
    @GetMapping("/selectAll")
    public R<List<Susceptible>> selectAll(){
        List<Susceptible> susceptibleList = susceptibleMapper.selectList(null);
        return R.success(susceptibleList);
    }


    /**
     * 添加敏感词
     * @param susceptible
     * @return
     */
    @PostMapping("/addSusceptible")
    public R<String> addSusceptible(@RequestBody Susceptible susceptible){
        susceptibleMapper.insert(susceptible);
        return R.success("添加成功");
    }

    /**
     * 修改敏感词
     * @param susceptible
     * @return
     */
    @PutMapping("/reviseSusceptible")
    public R<String> reviseSusceptible(@RequestBody Susceptible susceptible){
        susceptibleMapper.updateById(susceptible);
        return R.success("修改成功");
    }

    /**
     * 删除
     * @return
     */
    @DeleteMapping("/deleteSusceptible/{id}")
    public R<String> deleteSusceptible(@PathVariable Long id){
        susceptibleMapper.deleteById(id);
        return  R.success("删除成功");
    }
}
